﻿using Microsoft.EntityFrameworkCore;
using System.ComponentModel.DataAnnotations.Schema;
using System.Text.Json.Serialization;

namespace EasyDDD.Domain.User
{
    /// <summary>
    /// 用户和角色关联
    /// </summary>
    [PrimaryKey(nameof(UserId), nameof(RoleId))]
    public class ApplicationUserRole
    {
        [JsonConstructor]
        public ApplicationUserRole() { }

        /// <summary>
        /// Gets or sets the primary key of the user that is linked to a role.
        /// </summary>
        [ForeignKey(nameof(ApplicationUser))]
        public virtual Guid UserId { get; set; } = default!;
        public virtual ApplicationUser ApplicationUser { get; set; } = default!;


        /// <summary>
        /// Gets or sets the primary key of the role that is linked to the user.
        /// </summary>

        [ForeignKey(nameof(ApplicationRole))]
        public virtual Guid RoleId { get; set; } = default!;
        public virtual ApplicationRole ApplicationRole { get; set; } = default!;
    }
}

